<template>
	<view class="content">
		<u-navbar title="提領" placeholder autoBack>
			<view class="flexright xiaohei" slot="right" @click="goBindingAccount">
				<view class="toprightbtn">
					綁定帳號
				</view>
			</view>
		</u-navbar>
		<view class="mainpadding">
			<view class="ffffff shadow" style="border: 1rpx solid #e3e1e6;border-radius: 20rpx;">
				<view class="mainpadding" style="border-bottom: 1rpx dashed #e3e1e6;"
					@click="jumpurl('/pages_mine/bindingAccount?type=1')">
					<view class="flexbetween" v-if="!currentid">
						<view class="main_size hei_text bold">選擇銀行帳戶</view>
						<u-icon name="arrow-right" color="#333" size="16"></u-icon>
					</view>
					<view class="flexbetween" v-if="currentid">
						<view class="">
							<view class="bold titletext margin_right2">{{seleckBankItem.bank}}
							</view>
							<view class="titletext bold margin_top1">{{seleckBankItem.num}}</view>
						</view>
		
						<u-icon name="arrow-right" color="#333" size="16"></u-icon>
					</view>
				</view>
				<view class="xiaohei titletext bold mainpadding" style="border-bottom: 1rpx dashed #e3e1e6;">
					電口支付 點數：<text class="xiaohong" style="font-size: 40rpx;">{{allMoney}}</text>
				</view>
				<view class="flexbetween mainpadding">
					<view class="xiaohui bold" style="font-size: 40rpx;">$</view>
					<input type="text" placeholder="0" style="font-size: 40rpx;" v-model="money"
						class="xiaohong textright bold" />
				</view>
			</view>
			<view class="mainpadding_top ffffff radius">
				<view class="main_size hei_text bold">提領規則</view>
				<view class="xiaohui margin_top1">{{listbz}}</view>
			</view>
			<view class="submitbtn margin_top" @click="tixian">提領</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cardList: [],
				currentid: "",
				allMoney: "",
				money: "",
				listbz:"",
				seleckBankItem: {}
			}
		},
		onShow() {
			this.getlist()
			this.beizhu()
		},
		onLoad() {
			uni.$on("seleckBank", data => {
				this.currentid = data.id
				this.seleckBankItem = data
			})
		},
		onUnload() {
			uni.$off("seleckBank")
		},
		methods: {
			beizhu(){//提现备注
				let _this=this
				this.http.request('/api/index/getConfigInfoItem','GET',{
					pidtype:"otherset",
					type:"userwithdrawal_des"
				}).then(res=>{
					this.listbz=res.data
				})
			},
			tixian() {
				if (this.money == "") {
					this.http.toast("請輸入提領金額")
					return false
				}
				if (Number(this.allMoney) < Number(this.money)) {
					this.http.toast("提領金額不可大於點數")
					return false
				}
				if (this.currentid == "") {
					this.http.toast("暂未綁定帳戶，无法提領")
					return false
				}
				this.http.request("/api/member/addWithdrawal", 'POST', {
					user_bank_id: this.currentid,
					price: this.money
				}).then(res => {
					if (res.code == 1) {
						this.http.toast("提領申請已提交審核")
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}else{
						this.http.toast(res.msg)
					}
				})
			},
			getlist() { //獲取個人信息
				let _this = this
				let url = "/api/member/zcgl"
				this.http.request(url, 'POST', {}).then(res => {
					this.allMoney = res.data.money
				})
			},
			returnnum(str) {
				return str.substr(-4)
			},
			goBindingAccount() { //綁定帳戶
				uni.navigateTo({
					url: "/pages_mine/bindingAccount"
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.header {
		height: 241.68rpx;
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		background-color: rgba(255, 184, 0, 1);
	}

	.totalBox {
		font-size: 40rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FFFFFF;

		.total_price {
			font-size: 72rpx;
		}
	}

	.withdrawalBox {
		height: 206rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		padding: 30rpx 40rpx;
		box-sizing: border-box;
		margin: 0 auto;
		margin-top: -60rpx;

		.withdrawalItem {
			font-size: 40rpx;
			font-family: DIN Next LT Pro-Regular, DIN Next LT Pro;
			font-weight: 400;
			color: #333333;
		}

		.withdrawalPrice {
			width: 400rpx;
			font-size: 64rpx;
		}
	}
</style>